#ifndef _MPxSurfaceShape
#define _MPxSurfaceShape
//-
// ==========================================================================
// Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors.  All
// rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its
// licensors,  which is protected by U.S. and Canadian federal copyright law
// and by international treaties.
//
// The Data may not be disclosed or distributed to third parties or be
// copied or duplicated, in whole or in part, without the prior written
// consent of Autodesk.
//
// The copyright notices in the Software and this entire statement,
// including the above license grant, this restriction and the following
// disclaimer, must be included in all copies of the Software, in whole
// or in part, and all derivative works of the Software, unless such copies
// or derivative works are solely in the form of machine-executable object
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
// ==========================================================================
//+
//
// CLASS:    MPxSurfaceShape
//
// ****************************************************************************

#if defined __cplusplus

// ****************************************************************************
// INCLUDED HEADER FILES


#include <maya/MStatus.h>
#include <maya/MTypes.h>
#include <maya/MObject.h>
#include <maya/MPxNode.h>
#include <maya/MBoundingBox.h>

// ****************************************************************************
// DECLARATIONS

class MDagPath;
class MSelectArgs;
class MSelectionList;
class MPointArray;
class MObjectArray;
class MSelectionMask;
class MAttributeSpecArray;
class MVectorArray;
class MDoubleArray;
class MPxGeometryIterator;

// ****************************************************************************
// CLASS DECLARATION (MPxSurfaceShape)

//! \ingroup OpenMaya MPx
//! \brief Parent class of all user defined shapes. 
/*!
  MPxSurfaceShape is the parent class of all user defined shapes.
  User defined shapes are dependency nodes (and DAG nodes) which contain
  overridable drawing, selection, and component methods.

  This class can be used to implement new kinds of shapes within Maya that
  can have selectable/manipulatable components and behave in a similar
  manner to the default shapes in maya.

  The UI dependent aspects of the shape should be implemented in a class
  derived from MPxSurfaceShapeUI. This includes the drawing and interactive
  selection of the shape and any components that the shape implements.
*/
class OPENMAYA_EXPORT MPxSurfaceShape : public MPxNode
{
public:
	MPxSurfaceShape();
	virtual ~MPxSurfaceShape();
	virtual MPxNode::Type type() const;


	// ************************************************************
	// Methods to overload

	virtual bool		    isBounded() const;
	virtual MBoundingBox    boundingBox() const;

	//! Vertex caching modes.
	enum MVertexCachingMode {
		kNoPointCaching,	//!< No point caching.
		kSavePoints,		//!< Points should be saved for undo in the point cache.
		kRestorePoints,		//!< Points should be restored from the point cache.
		kUpdatePoints		//!< Update the points.
	};

	// Move tool support for components
	virtual void		    transformUsing( const MMatrix& mat,
							    			const MObjectArray& componentList );
	virtual void		    transformUsing( const MMatrix& mat,
							    			const MObjectArray& componentList,
											MVertexCachingMode cachingMode,
											MPointArray* pointCache);
	virtual void		    tweakUsing( const MMatrix& mat,
										const MObjectArray& componentList,
										MVertexCachingMode cachingMode,
										MPointArray* pointCache,
										MArrayDataHandle& handle );
	bool					convertToTweakNodePlug(MPlug& plug) const;

	//! Vertex offset modes.
	enum MVertexOffsetMode {
		kNormal,			//!< Move in normal direction.
		kUTangent,			//!< Move in u tangent direction.
		kVTangent,			//!< Move in v tangent direction.
		kUVNTriad			//!< Calculate u, v, and normal offsets.
	};

	virtual bool			vertexOffsetDirection( MObject & component,
                                                   MVectorArray & direction,
                                                   MVertexOffsetMode mode,
												   bool normalize );
	virtual MObject			newControlPointComponent( ) const;

	virtual void			componentToPlugs( MObject& component,
											  MSelectionList& selectionList
											) const;
	virtual bool			match( const MSelectionMask & mask,
					    		   const MObjectArray& componentList ) const;

	//! Return values for the matchComponent() method.
	enum MatchResult {
		//! The component was matched without error.
		kMatchOk,
		//! No component was matched.
		kMatchNone,
		//! Not used.
		kMatchTooMany,
		//! One of the names in the attribute specification was not valid.
		kMatchInvalidName,
		//! Not used.
		kMatchInvalidAttribute,
		//! The attribute specification contained an index for a non-array
		//! attribute.
		kMatchInvalidAttributeIndex,
		//! An attribute index was out of range.
		kMatchInvalidAttributeRange,
		//! The attribute specification provided the wrong number of dimensions
		//! for an attribute.
		kMatchInvalidAttributeDim
	};
	virtual MatchResult		matchComponent( const MSelectionList& item,
											const MAttributeSpecArray& spec,
											MSelectionList& list );

	virtual MObject			createFullVertexGroup() const;

	virtual bool deleteComponents( const MObjectArray& componentList,
								   MDoubleArray& undoInfo );
	virtual bool undeleteComponents( const MObjectArray& componentList,
									 MDoubleArray& undoInfo );

	virtual MObject 		localShapeInAttr() const;
	virtual MObject 		localShapeOutAttr() const;
	virtual MObject 		worldShapeOutAttr() const;
	virtual MObject 		cachedShapeAttr() const;

	virtual MObject			geometryData() const;

	virtual void			closestPoint( const MPoint& toThisPoint,
										  MPoint& theClosestPoint,
										  double tolerance );
	virtual bool			pointAtParm( const MPoint& atThisParm,
										  MPoint& evaluatedPoint );

	// Geometry iterator methods
	//
	virtual	MPxGeometryIterator *
							geometryIteratorSetup( MObjectArray&, MObject&,
												   bool forReadOnly = false );
	virtual bool			acceptsGeometryIterator( bool  writeable=true );
	virtual bool			acceptsGeometryIterator( MObject&,
													 bool writeable=true,
													 bool forReadOnly = false);

	// ************************************************************

	MObjectArray 			activeComponents() const;
	bool					hasActiveComponents() const;

	//! Scope of change.
	enum MChildChanged {
		//! Object geometry changed. Internal caches need to be updated.
		kObjectChanged,
		//! Object geometry is unchanged but its bounding box has changed. This
		//! might happen if the object was moved or an offset changed.
		kBoundingBoxChanged
	};
	void                    childChanged( MChildChanged = kObjectChanged );

	// Marking the object as renderable allows the shaders to be hooked up
    bool                    isRenderable() const;
	void			        setRenderable( bool );

	MMatrix		getWorldMatrix( MDataBlock &, unsigned int ) const;

	// ************************************************************

    // Inherited attributes

	// If true, the object has history and the control point attribute
	// values are tweaks, not the actual values.
	static MObject mHasHistoryOnCreate;

	//! Control points for the derived shapes
	static MObject mControlPoints;
		//! X value of a control point
		static MObject mControlValueX;
		//! Y value of a control point
		static MObject mControlValueY;
		//! Z value of a control point
		static MObject mControlValueZ;

	//! bounding box attribute
	static MObject nodeBoundingBox;
	    //! bounding box minimum point
	    static MObject nodeBoundingBoxMin;
	        //! X component of boundingBoxMin
	        static MObject nodeBoundingBoxMinX;
	        //! Y component of boundingBoxMin
	        static MObject nodeBoundingBoxMinY;
	        //! Z component of boundingBoxMin
	        static MObject nodeBoundingBoxMinZ;
	    //!  bounding box maximum point
	    static MObject nodeBoundingBoxMax;
	        //! X component of boundingBoxMax
	        static MObject nodeBoundingBoxMaxX;
	        //! Y component of boundingBoxMax
	        static MObject nodeBoundingBoxMaxY;
	        //! Z component of boundingBoxMax
	        static MObject nodeBoundingBoxMaxZ;
	    //!  bounding box size vector
	    static MObject nodeBoundingBoxSize;
	        //! X component of boundingBoxSize
	        static MObject nodeBoundingBoxSizeX;
	        //! Y component of boundingBoxSize
	        static MObject nodeBoundingBoxSizeY;
	        //! Z component of boundingBoxSize
	        static MObject nodeBoundingBoxSizeZ;
	//! object center attribute
	static MObject center;
	    //! X component of boundingBoxCenter
	    static MObject boundingBoxCenterX;
	    //! Y component of boundingBoxCenter
	    static MObject boundingBoxCenterY;
	    //! Z component of boundingBoxCenter
	    static MObject boundingBoxCenterZ;
	//! matrix attribute
	static MObject matrix;
	//! inverse matrix attribute
	static MObject inverseMatrix;
	//! world matrix attribute
	static MObject worldMatrix;
	//! inverse world matrix attribute
	static MObject worldInverseMatrix;
	//! parent matrix attribute
	static MObject parentMatrix;
	//! inverse parent matrix attribute
	static MObject parentInverseMatrix;
	//! visibility attribute
	static MObject visibility;
	//! intermediate object attribute
	static MObject intermediateObject;
	//! template attribute
	static MObject isTemplated;
	//! instances object group info attribute
	static MObject instObjGroups;
	    //! object groups attributes
	    static MObject objectGroups;
	        //! component in object groups attribute
	        static MObject objectGrpCompList;
	        //! group id attribute
	        static MObject objectGroupId;
	        //! group id attribute
	        static MObject objectGroupColor;
	//! controls choice of wireframe dormant object color
	static MObject useObjectColor;
	//! the per object dormant wireframe color
	static MObject objectColor;

	static const char*	    className();

protected:

private:
	static void				initialSetup();
};

#endif /* __cplusplus */
#endif /* _MPxSurfaceShape */
